package com.tuanbiao.ui.blast;

import android.content.Context;
import android.content.Intent;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.hzjq.lib.cap.bean.ErrorCap;
import com.tuanbiao.base.BaseActivity;
import com.tuanbiao.databinding.ActivityBlastCheckErrorBinding;
import com.tuanbiao.events.BlastErrorEvent;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.List;

public class BlastCheckErrorActivity extends BaseActivity<ActivityBlastCheckErrorBinding> {
    private List<ErrorCap> mErrorCaps;
    private BlastCheckErrorAdapter blastCheckErrorAdapter;

    public static void start(Context context) {
        Intent starter = new Intent(context, BlastCheckErrorActivity.class);
        context.startActivity(starter);
    }


    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void init(BlastErrorEvent event) {
        mErrorCaps = event.getErrorCaps();
        EventBus.getDefault().removeStickyEvent(event);
    }

    @Override
    protected ActivityBlastCheckErrorBinding getBindingView() {
        return ActivityBlastCheckErrorBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void initView() {
        binding.srlContent.setEnableLoadMore(false);
        binding.ivToolbarBack.setOnClickListener(getBackListener());
        binding.rvContent.setLayoutManager(new LinearLayoutManager(getActivity()));
        blastCheckErrorAdapter = new BlastCheckErrorAdapter();
        binding.rvContent.setAdapter(blastCheckErrorAdapter);
        blastCheckErrorAdapter.setNewInstance(mErrorCaps);
    }


    @Override
    protected boolean userEventbus() {
        return true;
    }
}